]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
status/bluetooth: Bail out and hide UI when there's no adapter
authorJonas Dreßler <verdre@v0yd.nl>
Mon, 31 Jan 2022 22:40:39 +0000 (23:40 +0100)
committerMarge Bot <marge-bot@gnome.org>
Fri, 18 Feb 2022 19:10:18 +0000 (19:10 +0000)
While _sync() does already handle the case where there's no adapter just
fine (hiding the item and the indicator), let's make the handling a bit
more obvious and add an explicit check for !this._adapter where we bail
out and hide the UI.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2188>

js/ui/status/bluetooth.js

index a7768c824e1dd1d221a85bf4e23ca301642f7d47..d84bc3ad5668f61a586f4449a70e0df65fa21806 100644 (file)
@@ -130,13 +130,20 @@ class Indicator extends PanelMenu.SystemIndicator {
     }
 
     _sync() {
-        let devices = this._getDeviceInfos();
+        const adapterJustAppeared = !this._adapter && this._client.default_adapter;
+        this._adapter = this._client.default_adapter ?? null;
+        if (!this._adapter) {
+            this._item.visible = false;
+            this._indicator.visible = false;
+            return;
+        }
+
+        const devices = this._getDeviceInfos();
         const connectedDevices = devices.filter(dev => dev.connected);
         const nConnectedDevices = connectedDevices.length;
 
-        if (this._client.default_adapter && this._adapter)
+        if (!adapterJustAppeared)
             this._setHadSetupDevices(devices.length > 0);
-        this._adapter = this._client.default_adapter ?? null;
 
         let sensitive = !Main.sessionMode.isLocked && !Main.sessionMode.isGreeter;